const express = require('express')
const app = express()
const router = express.Router()
const data = require('../data.json')
const seller = data.seller
const goods = data.goods
const ratings = data.ratings

app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});

router.get('/seller', function(req, res){
    return res.json({
      status: 0,
      message: seller
    })
})

router.get('/goods', function(req, res){
  return res.json({
    status: 0,
    message: goods
  })
})

router.get('/ratings', function(req, res){
  return res.json({
    status: 0,
    message: ratings
  })
})

app.use('/api', router);
app.listen('3001',function(){
  console.log('3001 run');
})
